package com.itheima.TCP.TCP接收协议;


import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo5 {
    public static void main(String[] args) throws IOException {
        //创建服务器对象
        ServerSocket ss = new ServerSocket(2);
        //服务器接收请求
        Socket accept = ss.accept();
        //把接收的数据转为字节输入流
        InputStream is = accept.getInputStream();
        //字节转字符
        InputStreamReader isr = new InputStreamReader(is);
        //把字符转为字符缓冲输入流
        BufferedReader br = new BufferedReader(isr);
        //调用字符缓冲输入流的字符串一次读取一行的方法
        String s = br.readLine();
        //打印字符串l
        System.out.println(s);
        //关流释放资源
            accept.close();
            ss.close();
    }
}
